package command;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

import server.CommandFactories.CmdType;

import command.protobuf.MessageBufProtoBuf.RpcMessage;

public class ExceptionResponseFactory implements ICommandFactory {
	public static class ExceptionResponse implements IResponse {
		String ex;

		public ExceptionResponse(String ex) {
			this.ex = ex;
		}

		@Override
		public void read(InputStream input) throws IOException {
			ex = new DataInputStream(input).readUTF();
		}

		@Override
		public void write(OutputStream output) throws IOException {
			new DataOutputStream(output).writeUTF(ex);
		}

		@Override
		public Object get() {
			return ex;
		}

		@Override
		public void set(Object content) {
			this.ex = (String)content;
		}

		@Override
		public short getCmdType() {
			return (short) CmdType.exceptionresponse.ordinal();
		}
	}

	@Override
	public ICommand createCommand() {
		return null;
	}

	@Override
	public IResponse createResponse() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ICallback createCallback() {
		return null;
	}

}
